package com.ce.service.impl;

import com.ce.entity.Storage;
import com.ce.mapper.StorageMapper;
import com.ce.service.StorageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author jyt
 * @since 2022-03-04
 */
@Service
public class StorageServiceImpl extends ServiceImpl<StorageMapper, Storage> implements StorageService {

    /**
     * 获取库存列表
     */
    @Resource
    private StorageMapper mapper;

    @Override
    public List<Storage> getList() {
        return mapper.selectList(null);
    }

    /**
     * 库存调整
     */
    @Override
    public Map<String, String> updateStorage(Storage storage) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("mode", "update one storage");
        mapper.update(storage);
        return map;
    }

    /**
     * 添加库存
     */
    @Override
    public Map<String, String> updateStorageList(Storage storage) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("mode", "update one storage");
        mapper.updateStorage(storage);
        return map;
    }

    /**
     * 减少库存
     */
    @Override
    public Map<String, String> reduceStorageList(Storage storage) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("mode", "update one storage");
        mapper.reduceStorage(storage);
        return map;
    }

    @Override
    public Storage selectByProductNoAndWarehouseNo(Storage storage) {
        return mapper.selectByProductNoAndWarehouseNo(storage);
    }

    @Override
    public Map<String, String> addStorageList(Storage storage) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("mode", "insert one storage");
        mapper.insert(storage);
        return map;
    }
}
